﻿/// <reference path="../libraries/q.js" />
/// <reference path="../filehandler.js" />

var HtmlHelper = (function () {
    var VIEWS_ADDRESS = "www/Views/";

    var loadView = function (viewName, selector) {
        var defer = Q.defer();

        FileHandler.readTextFile(VIEWS_ADDRESS + viewName + ".html").then(function (viewCode) {
            $(selector).html(viewCode);
            defer.resolve(true);
        }, function (error) {
            defer.reject(error);
            $(selector).html("Error loading view: " + viewName);
        });

        return defer.promise;
    }

    return {
        loadView: loadView
    }

}())